﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true"
    CodeBehind="frmLaborMinera.aspx.cs" EnableEventValidation="false" Inherits="MC.SMC.UI.Lab.frmLaborMinera" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        $(function () {
            var RowID = $("#<%=hdCodigoLabor.ClientID %>").val();
            if (RowID != "0") {
                $('#<%=gvLaborMinera.ClientID%> tr[id=' + RowID + ']').css({ "background-color": "Black", "color": "White" });
            }
            $('#<%=gvLaborMinera.ClientID%> tr[id]').click(function () {
                $('#<%=gvLaborMinera.ClientID%> tr[id]').css({ "background-color": "White", "color": "Black" });
                $(this).css({ "background-color": "Black", "color": "White" });
                $("#<%=hdCodigoLabor.ClientID %>").val($(this).attr("id"));
            });
            $('#<%=gvLaborMinera.ClientID%> tr[id]').mouseover(function () {
                $(this).css({ cursor: "hand", cursor: "pointer" });
            });


        });

        function pageLoad() {
            $(".spin").spinner({
                min: 0
            });
            $(".boton").button();
        }

        //ELIMINAR
        var confirmed = false;
        function confirmDialog(obj) {
            if (!confirmed) {
                $("#dialog-confirm").dialog({
                    title: 'Confirmación',
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        "Yes": function () {
                            $(this).dialog("close");
                            confirmed = true; obj.click();
                        },
                        "No": function () {
                            $(this).dialog("close");
                        }
                    }
                });
            }

            return confirmed;
        }

        //VALIDAR
        var confirmedFinalizar = false;
        function confirmValidar(obj) {
            if (!confirmedFinalizar) {
                $("#dialog-validar").dialog({
                    title: 'Confirmación',
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        "Yes": function () {
                            $(this).dialog("close");
                            confirmedFinalizar = true; obj.click();
                        },
                        "No": function () {
                            $(this).dialog("close");
                        }
                    }
                });
            }
            return confirmedFinalizar;
        }

        function Forzar() {
            __doPostBack('', '');
        }

    </script>

    <script type="text/javascript">
        function soloNumeros(evt) {
            var nav4 = window.Event ? true : false;
            var key = nav4 ? evt.which : evt.keyCode;
            return (key <= 13 || (key >= 48 && key <= 57));
        }

    </script>

    <div class="navegacion">
        <asp:Label runat="server" ID="lblNavegacion" Text="" />
    </div>

    <table>
        <tr>
            <td>
                <h1>
                    Labor Minera</h1>
            </td>
        </tr>
    </table>
    <fieldset style="height: 60px;">
        <table width="100%">
            <tr>
                <td>
                    Nombre Labor:
                </td>
                <td>
                    <asp:UpdatePanel ID="updNombre" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:TextBox ID="txtNombreLabor" runat="server" Width="300px" CssClass="CajaTexto" MaxLength="20"></asp:TextBox>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <asp:HiddenField ID="hdCodigoLabor" runat="server" Value="0" />
                <asp:HiddenField ID="hdValidado" runat="server" Value="0" />
                <asp:HiddenField ID="hdCorrelativo" runat="server" Value="0" />
                <asp:HiddenField ID="hdNombreLabor" runat="server" Value="0" />
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Button ID="btnFiltrar" runat="server" Text="Labor" class="botton" OnClick="btnFiltrar_Click"
                                Width="100px"></asp:Button>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
                <td>
                    <asp:Button ID="btnBuscar" runat="server" Text="Buscar" class="botton" OnClick="btnBuscar_Click"
                        Width="100px"></asp:Button>
                </td>
                <td>
                    <asp:Button ID="btnExportar" runat="server" Text="Exportar" class="botton" OnClick="btnExportar_Click"
                        Width="100px"></asp:Button>
                </td>
            </tr>
        </table>
    </fieldset>
    <table style="margin: 10px;">
        <tr>
            <td>
                <asp:GridView ID="gvLaborMinera" runat="server" AutoGenerateColumns="False" Width="950px"
                    AllowPaging="true" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
                    PageSize="8" OnPageIndexChanging="gvLaborMinera_PageIndexChanging" OnRowDataBound="gvLaborMinera_RowDataBound"
                    DataKeyNames="CodigoLabor">
                    <Columns>
                        <asp:BoundField DataField="CodigoLabor" HeaderText="Codigo" />
                        <asp:BoundField DataField="Nombre" HeaderText="NombreLabor" />
                        <asp:BoundField DataField="Zona" HeaderText="Zona" />
                        <asp:BoundField DataField="Nivel" HeaderText="Nivel" />
                        <asp:BoundField DataField="Cuerpo" HeaderText="Cuerpo" />
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
    </table>
    <fieldset style="height: 30px; vertical-align: middle">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table width="100%" style="vertical-align: middle">
                    <tr>
                        <td>
                            <asp:Button ID="btnRegistrar" runat="server" Text="Registrar" class="botton" OnClick="btnRegistrar_Click"
                                Width="100px"></asp:Button>
                        </td>
                        <td>
                            <asp:Button ID="btnActualizar" runat="server" Text="Actualizar" class="botton" OnClick="btnActualizar_Click"
                                Width="100px"></asp:Button>
                        </td>
                        <td>
                            <asp:Button ID="btnEliminar" runat="server" Text="Eliminar" class="botton" OnClick="btnEliminar_Click"
                                OnClientClick="return confirmDialog(this);" Width="100px"></asp:Button>
                        </td>
                        <td>
                            <asp:Button ID="btnSalir" runat="server" Text="Salir" class="botton" OnClick="btnSalir_Click"
                                 Width="100px"></asp:Button>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnEliminar" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </fieldset>
    <div id="dialog-confirm" style="display: none;">
        ¿Está seguro de eliminar este registro?
    </div>
    <div id="dialog-validar" style="display: none;">
        ¿Está seguro de cerrar la Muestra?
    </div>
    <!--MODAL MANTENEDOR-->
    <div id="addModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
        aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>
            <h3 id="addModalLabel">
                Grabar Labor Minera</h3>
        </div>
        <asp:UpdatePanel ID="upAdd" runat="server">
            <ContentTemplate>
                <div class="modal-body">
                    <table class="table table-bordered table-hover table-condensed">
                        <tr>
                            <td>
                                Nombre Labor:
                            </td>
                            <td>
                                <asp:TextBox ID="txtNombreLaborPopup" runat="server" Enabled="false"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Categoría:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCategoria" runat="server" CssClass="ComboBox">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Tipo Labor:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlTipoLabor" runat="server" CssClass="ComboBox" 
                                    AutoPostBack="True" onselectedindexchanged="ddlTipoLabor_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Nivel:
                            </td>
                            <td>
                                <asp:TextBox ID="txtNivel" runat="server"  MaxLength="3" AutoPostBack="True"  onkeypress="return soloNumeros(event);"
                                    ontextchanged="txtNivel_TextChanged"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Sección:
                            </td>
                            <td>
                                <asp:TextBox ID="txtSeccion" MaxLength="3" runat="server" class="spin" AutoPostBack="True" onkeypress="return soloNumeros(event);"
                                    ontextchanged="txtSeccion_TextChanged"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Dirección:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlDireccion" runat="server" CssClass="ComboBox" 
                                    AutoPostBack="True" onselectedindexchanged="ddlDireccion_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Zona:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlZona" runat="server" CssClass="ComboBox">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Cuerpo:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCuerpo" runat="server" CssClass="ComboBox">
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="btnAgregarLaborMinera" runat="server" Text="Guardar" CssClass="botton"
                        OnClick="btnAgregarLaborMinera_Click" />
                    <button class="botton" data-dismiss="modal" aria-hidden="true">
                        Cancelar</button>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAgregarLaborMinera" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <!--MODAL BUSCAR-->
    <div id="showBuscar" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
        aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>
            <h3 id="H1">
                Seleccionar Labor</h3>
        </div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <div class="modal-body">
                    <table class="table table-bordered table-hover table-condensed">
                        <tr>
                            <td>
                                Nombre:
                            </td>
                            <td>
                                <asp:TextBox ID="txtNombreBuscador" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:Button ID="btnBuscadorLabor" runat="server" Text="Buscar" CssClass="boton" OnClick="btnBuscadorLabor_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <asp:GridView ID="gvConsulta" runat="server" AutoGenerateColumns="False" Width="450px"
                                    AllowPaging="true" CssClass="grillaConsulta" OnRowCommand="gvConsulta_RowCommand"
                                    PageSize="6" OnPageIndexChanging="gvConsulta_PageIndexChanging" OnRowDataBound="gvConsulta_RowDataBound"
                                    DataKeyNames="Nombre">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Sel.">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="ibtnSeleccionar" runat="server" CausesValidation="false" CommandArgument='<%# Eval("Nombre") %>'
                                                    CommandName="Seleccionar" ImageUrl="~/App_Themes/Imagenes/cargar_archivo.gif"
                                                    ToolTip="Seleccionar" />
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="Nombre" HeaderText="Nombre" />
                                        <asp:BoundField DataField="Zona" HeaderText="Zona" />
                                        <asp:BoundField DataField="Nivel" HeaderText="Nivel" />
                                        <asp:BoundField DataField="Cuerpo" HeaderText="Cuerpo" />
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button class="boton" data-dismiss="modal" aria-hidden="true">
                        Cancelar</button>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnBuscadorLabor" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
